package com.test.daily.leetcode.y2022.m05.day0521.v01;

import java.util.HashMap;

/**
 * @descriptions: Solution
 * @author: Tom
 * @date: 2022/5/21 上午 11:27
 * @version: 1.0
 */
public class Solution {
    public int repeatedNTimes(int[] nums) {
        HashMap<Integer, Integer> map = new HashMap<>();
        int ans = nums[0];
        for(int i = 0; i < nums.length / 2 + 1; i++){
            int  count = map.getOrDefault(nums[i], 0);
            if(count > 0){
                ans = nums[i];
                break;
            }
            map.put(nums[i], count +1);
        }
        return ans;
    }
}
